<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>水果列表页面</title>
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <style>
        table tr:first-of-type{
            background-color: gray;
        }
        tr:nth-of-type(odd){
            background-color: indianred;
        }
    </style>
</head>
<body>
    <table border="1px">
        <tr>
            <th>类别</th>
            <th>品种</th>
            <th>产地</th>
            <th>总重量(公斤)</th>
            <th>单价(元/公斤)</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${list}" var="fruit">
            <tr>
                <th>${fruit.type}</th>
                <th>${fruit.breed}</th>
                <th>${fruit.area}</th>
                <th>${fruit.weight}</th>
                <th>${fruit.price}</th>
                <th>
                    <a href="Detail/${fruit.fruitId}">详细</a>
                    <a href="javascript:void(0)" onclick="del(${fruit.fruitId})">删除</a>
                </th>
            </tr>
        </c:forEach>
    </table>
</body>
<script>
    function del(fruitId){
        $.post("delete","fruitId="+fruitId,function(data){
            alert(data)
            if(data){
                alert('删除成功');
                location.reload();
            }else{
                alert('删除失败')
                location.reload();
            }
        })
    }
</script>
</html>
